<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('用户列表')" />
	<th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								ID：<input type="text" name="id"/>
							</li>

							<li>
								姓名：<input type="text" name="realname"/>
							</li>


							<li>
								微信名称：<input type="text" name="nickname"/>
							</li>

							<li>用户类型： <select name="renzheng"
								class="selectpicker show-tick " data-live-search="true"
								data-none-selected-text="请选择">
									<option></option>
									<option value="0">普通用户</option>
									<option value="2">骑手用户</option>
							</select>
							</li>

							<li>分销商： <select name="chiefPermission"
								class="selectpicker show-tick " data-live-search="true"
								data-none-selected-text="请选择">
									<option></option>
									<option value=1>分销商</option>
									<option value=0>非分销商</option>
							</select>
							</li>

							<!--<li>-->
								<!--<label>校区： </label>-->
								<!--<input type="text"  id="riderSchool" placeholder="校区" name="params[riderSchool]"/>-->
							<!--</li>-->
							<li>校区：<select  id = "schools" name="schools" class="selectpicker  "
										   data-live-search="true" data-none-selected-text="请选择">
								<option></option>
								<option></option>
								<option th:each="school:${schoolList}" th:value="${school.schoolName}"
										th:text="${school.schoolName}"></option>
							</select>
							</li>





							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>

	        <div class="btn-group-sm" id="toolbar" role="group">

				<a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="User:user:remove">
					<i class="fa fa-remove"></i> 删除
				</a>

			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('User:user:edit')}]];
        var removeFlag = [[${@permission.hasPermi('User:user:remove')}]];
        var prefix = ctx + "User/user";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "用户",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id',
					title : '',
					visible: false
				},

				{
					title: '头像',
				    formatter: function(value, row, index) {
				    	if($.common.isEmpty(row.avatar)){
				    		return $.table.imageView('http://demo.ruoyi.vip/ruoyi.png');
				    	} else {
				    		return $.table.imageView(row.avatar);
				    	}
				    	// 图片预览（注意：如存储在本地直接获取数据库路径，如有配置context-path需要使用ctx+路径）
				    	// 如：/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
				    	/* if(index % 2 == 0){
				    		return $.table.imageView('/profile/avatar/2019/07/19/e9708796bb68b17dd1ffa1faea25ece7.jpg');
				    	}else {
				    		return $.table.imageView('http://demo.ruoyi.vip/ruoyi.png');
				    	} */
				    }
					},
				{
					field : 'realname',
					title : '姓名',
					sortable: true
				},
				{
					title: '性别',
				    formatter: function(value, row, index) {
				    	if(row.gender==1){
				    		return '男';
				    	} else if(row.gender==0) {
				    		return '女';
				    	} else {
				    		return '不详';
				    	}
					},
				},
				{
					field : 'mobile',
					title : '电话号码',
					sortable: true
				},

				{
					field : 'nickname',
					title : '微信名称',
					sortable: true
				},
				{
					field : 'credit2',
					title : '金币',
					sortable: true
				},
				{
					field : 'credit1',
					title : '账户余额',
					sortable: true
				},







		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="userUpdate(\'' + row.id + '\')"><i class="fa fa-edit"></i>用户详情</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="getAddress(\'' + row.id + '\')"><i class="fa fa-edit"></i>收货地址</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="getPacket(\'' + row.id + '\')"><i class="fa fa-edit"></i>红包</a> ');
                        actions.push('<a class="btn btn-default btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="getSign(\'' + row.id + '\')"><i class="fa fa-edit"></i>签到进度</a> ');
						actions.push('<a class="btn btn-warning btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="getMoney(\'' + row.id + '\')"><i class="fa fa-edit"></i>金额流向</a> ');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });

        function userUpdate(id) {
        	$.modal.open('用户详情', prefix + "/edit/" + id, '1300', '800');
		}

        // function getAddress(id) {
        // 	$.modal.open('查看地址', prefix + "/getAddress/" + id, '1300', '800');
		// }

        // function getPacket(id) {
        // 	$.modal.open('查看红包', prefix + "/getPacket/" + id, '1300', '800');
		// }

        // function getSign(id) {
        // 	$.modal.open('查看签到进度', prefix + "/getSign/" + id, '1300', '800');
		// }
		//
		// function getMoney(id) {
		// 	$.modal.open('查看金额流向', prefix + "/getMoney/" + id, '1300', '800');
		// }

		function getAddress(id) {
			var options = {
				title: "查看地址",
				width: 1300,
				height: 800,
				url: prefix + "/getAddress/" + id,
				skin: 'layui-layer-gray',
				btn: ['关闭'],
				yes: function (index, layero) {
					layer.close(index);
				}
			};
			$.modal.openOptions(options);
		}

		function getPacket(id) {
			var options = {
				title: "查看红包",
				width: 1300,
				height: 800,
				url: prefix + "/getPacket/" + id,
				skin: 'layui-layer-gray',
				btn: ['关闭'],
				yes: function (index, layero) {
					layer.close(index);
				}
			};
			$.modal.openOptions(options);
		}

		function getSign(id) {
			var options = {
				title: "查看签到进度",
				width: 1300,
				height: 800,
				url: prefix + "/getSign/" + id,
				skin: 'layui-layer-gray',
				btn: ['关闭'],
				yes: function (index, layero) {
					layer.close(index);
				}
			};
			$.modal.openOptions(options);
		}

		function getMoney(id) {
			var options = {
				title: "查看金额",
				width: 1300,
				height: 800,
				url: prefix + "/getMoney/" + id,
				skin: 'layui-layer-gray',
				btn: ['关闭'],
				yes: function (index, layero) {
					layer.close(index);
				}
			};
			$.modal.openOptions(options);
		}
    </script>
</body>
</html>
